package com.tfos.study.controller;

import com.tfos.study.entity.Organization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * 类功能说明：机构管理控制类 <br/>
 * 公司名称：TF（腾飞）开源 <br/>
 * 作者：luorongxi <br/>
 */
@Slf4j
@RestController
@RequestMapping("/org")
public class OrganizationController {

    /**
     * 将对象转为json字符串 --> 序列化
     * @return
     */
    @RequestMapping(value = "/serializer/{averageSalary}", method = RequestMethod.GET)
    public Object serializer(@PathVariable("averageSalary") Long averageSalary) {
        Organization org = new Organization(
                1,
                "腾飞开源",
                "13800138000",
                "492699405@qq.com",
                "TF（腾飞）开源，致力于原创软件开源，提供基于JAVA的基础平台及解决方案，团队成员有丰富的智能设备和物联网平台相关经验，欢迎您的关注。",
                5,
                averageSalary,
                new Date()
        );
        return org;
    }

    /**
     * 将一个json转化为对象 --> 反序列化
     */
    @RequestMapping(value = "/deserialize")
    public String deserialize(@RequestBody Organization org) {
        log.warn("org=" + org.toString());
        return org.toString();
    }

}
